package proyecto.testcasetool.presentation.editor.pages;


import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.DetailsPart;
import org.eclipse.ui.forms.IDetailsPage;
import org.eclipse.ui.forms.IDetailsPageProvider;

import proyecto.testcasetool.Actor;
import proyecto.testcasetool.Subject;
import proyecto.testcasetool.UseCase;
import proyecto.testcasetool.presentation.details.usecase.ActorDetailsPage;
import proyecto.testcasetool.presentation.details.usecase.SubjectDetailsPage;
import proyecto.testcasetool.presentation.details.usecase.UseCaseDetailsPage;


public class MasterDetailsBlockUseCase extends AbstractMasterDetailsBlock {

	
	/**
	 * Default constructor. 
	 * The block is orientable.
	 */
	public MasterDetailsBlockUseCase() {
		super();
	}

	/**
	 * {@inheritDoc}
	 * @see org.eclipse.emf.eef.runtime.ui.widgets.masterdetails.AbstractEEFMasterDetailsBlock#createMasterPart(org.eclipse.swt.widgets.Composite)
	 */
	protected AbstractMasterPart createMasterPart(Composite masterContainer) {
		MasterPartUseCase masterPart = new MasterPartUseCase(toolkit, masterContainer, this);
		return masterPart;
	}
	
	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart)
	 */
	protected void registerPages(DetailsPart detailsPart) {
		detailsPart.setPageProvider(new IDetailsPageProvider() {

			public Object getPageKey(Object object) {
				return object;
			}

			public IDetailsPage getPage(Object key) {
				if(key instanceof UseCase){
					//lastDetailsPage = new DetailsPage(toolkit, editingDomain, adapterFactory);
					lastDetailsPage = new UseCaseDetailsPage(toolkit, editingDomain, getAdapterFactory());
					return lastDetailsPage;
				}
				else if (key instanceof Actor){
					lastDetailsPage = new ActorDetailsPage(toolkit, editingDomain, getAdapterFactory());
					return lastDetailsPage;
				}
				else if (key instanceof Subject){
					lastDetailsPage = new SubjectDetailsPage(toolkit, editingDomain, getAdapterFactory());
					return lastDetailsPage;
				}
				return null;
			}
		});
		
	}
	
}

